package com.zzz.assistant.myapplication;

import android.util.Log;

import java.lang.ref.WeakReference;

public class Utils {
    private static WeakReference<Utils> instance = null;

    private Utils(){}

    public static Utils getInstance() {
        if (instance == null || instance.get() == null) {
            instance = new WeakReference<Utils>(new Utils());
        }
        return instance.get();
    }

    public static String test() {
        String str = "instance is null? " + (instance == null);
        Log.i("test", "instance is null? " + (instance == null));
        if (instance != null) {
            Log.i("test", "instance.get is null?  " + (instance.get() == null));
            str += "\ninstance.get is null?  " + (instance.get() == null);
        }
        return str;
    }
}
